package com.auction.service.impl;

import com.auction.common.dao.MyBaseServiceImpl;
import com.auction.common.dao.bean.PageResult;
import com.auction.entity.Bidding;
import com.auction.mapper.BiddingMapper;
import com.auction.service.BiddingService;
import com.auction.utils.PageBidding;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Service
public class BiddingServiceImpl extends MyBaseServiceImpl<Bidding, BiddingMapper> implements BiddingService {
    @Autowired
    private BiddingMapper biddingMapper;
    @Override
    public PageResult<Bidding> getBiddingOrderByPrice(PageBidding pageBidding) {
        PageHelper.startPage(pageBidding.getPage(),pageBidding.getPageSize());
        int sign=pageBidding.getSign();
        List list = biddingMapper.getBiddingOrderByPrice(pageBidding);
        PageInfo<Bidding> pageInfo=new PageInfo<Bidding>(list);
        return new PageResult<>(pageBidding.getPage(),pageBidding.getPageSize(),pageInfo.getTotal(),list);
    }

    @Override
    public PageResult<Bidding> getBiddingOrderByTime(PageBidding pageBidding) {
        PageHelper.startPage(pageBidding.getPage(),pageBidding.getPageSize());
        int sign=pageBidding.getSign();
        List list = biddingMapper.getBiddingOrderByTime(pageBidding);
        PageInfo<Bidding> pageInfo=new PageInfo<Bidding>(list);
        return new PageResult<>(pageBidding.getPage(),pageBidding.getPageSize(),pageInfo.getTotal(),list);
    }

    @Override
    public int deleteIsDel(int id) {
        return biddingMapper.deleteIsDel(id);
    }
}
